<extend name="Public:base" />

<block name="title">业务员登陆</block>

<block name="header">
<header class="rol place-header">
    <div class="m-box">
        <a href="javascript:history.go(-1);" class="lt">
            <img src="__PUBLIC__/wx/img/return-1.png" class="pro-return-1" alt="">
        </a>
        <div class="lt pro-header-font">业务员登陆</div>
        <a href="{:U('Index/index')}" class="gt">
            <img src="__PUBLIC__/wx/img/home-1.png" class="pro-home-1" alt="">
        </a>
    </div>
</header>
</block>

<block name="content">
<div class="rol">
    <div class="m-box">
        <form action="__ACTION__" method="POST">
        <div class="rol sing-input-box1" style="height: auto">
            <div class="rol sign-input">
                <input type="text" name="name" id="name" placeholder="请输入姓名" maxlength="10" class="rol">
            </div>
            <div class="rol sign-input">
                <input type="tel" name="phone" id="phone" placeholder="请输入手机号" maxlength="11" class="rol">
            </div>
            <div class="rol sign-input">
                <input type="tel" name="varcode" id="varcode" placeholder="请输入验证码" class="rol" maxlength="6" autocomplete="off">
                <button type="button" class="sign-yz" id="sendphonecode">获取验证码</button>
            </div>
        </div>
        <button type="submit" class="rol sign-out1" id="golog">登陆</button>
        </form>
    </div>
</div>
<script>
$("#golog").on('click', function(e){
    var phone = $("#phone").val();
    
    var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;

    if(!myreg.test(phone)) { 
        alert('请输入有效的手机号码！'); 
        $("#phone").focus();
        return false; 
    }

    return true;
});
$("#sendphonecode").bind('click', function(e){
    var phonenum = $("#phone").val();

    var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
    if(!myreg.test(phonenum)) { 
        alert('请输入有效的手机号码！'); 
        $("#phone").focus();
        return false; 
    }

    $.ajax({
        url: '{:U('User/sendcode')}',
        type: 'POST',
        dataType: 'json',
        data: {'phonenum': phonenum},
    })
    .done(function(data) {
        if(data.code=='-1') {
            alert(data.msg);
            return false;
        } else if(data.code=='1') {
            alert(data.msg);
            $("#sendphonecode").attr("disabled", "disabled");
            $("#sendphonecode").timesend();
        }
    });
});

var timesec = 60;

jQuery.fn.timesend=function(){
    if(timesec==0) {
        timesec = 60;
        $("#sendphonecode").removeAttr("disabled");
        $("#sendphonecode").text('获取验证码');
    } else {
        $("#sendphonecode").attr("disabled", "disabled");
        $("#sendphonecode").text("重新获取("+timesec+")");
        timesec--;
        setTimeout(function() {
            $("#sendphonecode").timesend();
        },
        1000)
    }
}
</script>
</block>